MOD = 10**9+7

def mul(i,pos,dp):
  return ((i-pos+1)%MOD * dp[pos]%MOD)%MOD

def solve():
  dp = [0] * 1009
  x = input().strip()
  len_x = len(x)
  pos=-1
  dp[0] = 0
  
  for i in range (len_x):
    if x[i] == '1':
      pos=i
      dp[i]=1
      break
    
  if pos==-1:
    print("0")
    return
  
  for i in range(pos+1,len_x):
    if x[i] =="0":
      dp[i] = dp[i-1]
    else:
      dp[i] = mul(i,pos,dp)
      pos=i
      
  print(f"{dp[len_x-1]}")
  
def main() :
  T = int(input())
  
  for _ in range (T):
    solve()
    
if __name__ == "__main__":
  main()